home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Applications / Eudora 1.3.1 / source / winutil.c < prev   
Encoding:
C/C++ Source or Header  |  1993-03-16  |  19.1 KB  |  680 lines  |  [TEXT/MPS ]

  1. #define FILE_NUM 43
  2. /* Copyright (c) 1990-1992 by the University of Illinois Board of Trustees */
  3. /**********************************************************************
  4.  * various useful functions with at least a tenuous connection to windows
  5.  **********************************************************************/
  6. #pragma load EUDORA_LOAD
  7. #pragma segment Util
  8.  
  9. /**********************************************************************
  10.  * Get the maximum size of a window
  11.  **********************************************************************/
  12. void GetDisplayRect(Rect *rectPtr)
  13. {
  14.     rectPtr->top = qd.screenBits.bounds.top + 2*GetMBarHeight();
  15.     rectPtr->bottom = qd.screenBits.bounds.bottom;
  16.     rectPtr->left = qd.screenBits.bounds.left;
  17.     rectPtr->right = qd.screenBits.bounds.right;
  18.     
  19.     InsetRect(rectPtr,2,2);     /* leave a few pixels */
  20. }
  21.  
  22. /**********************************************************************
  23.  * force all windows to be redrawn
  24.  **********************************************************************/
  25. void RedrawAllWindows(void)
  26. {
  27.     WindowPeek theWindow;
  28.     Rect r;
  29.     
  30.     /*
  31.      * invalidate all windows
  32.      */
  33.     SetRect(&r,-INFINITY,-INFINITY,INFINITY,INFINITY);
  34.     for (theWindow = FrontWindow();
  35.          theWindow != nil ;
  36.          theWindow = theWindow->nextWindow)
  37.         RectRgn(theWindow->updateRgn,&r);
  38. }
  39.  
  40. /**********************************************************************
  41.  * SetDIText - set the text of a particular dialog item
  42.  **********************************************************************/
  43. void SetDIText(DialogPtr dialog,int item,UPtr text)
  44. {
  45.     short type;
  46.     Handle itemH;
  47.     Rect box;
  48.     
  49.     GetDItem(dialog,item,&type,&itemH,&box);
  50.     if (itemH!=nil)
  51.         SetIText(itemH,text);
  52. }
  53.  
  54. /**********************************************************************
  55.  * GetDIText - get the text of a particular dialog item
  56.  **********************************************************************/
  57. void GetDIText(DialogPtr dialog,int item,UPtr text)
  58. {
  59.     short type;
  60.     Handle itemH;
  61.     Rect box;
  62.     
  63.     GetDItem(dialog,item,&type,&itemH,&box);
  64.     if (itemH!=nil)
  65.         GetIText(itemH,text);
  66. }
  67.  
  68. /************************************************************************
  69.  * SetDIPopup - set a popup control to point to a string
  70.  ************************************************************************/
  71. UPtr SetDIPopup(DialogPtr pd,short item,UPtr toName)
  72. {
  73.     ControlHandle ch;
  74.     short itemType;
  75.     Rect itemRect;
  76.     short which;
  77.  
  78.     GetDItem(pd,item,&itemType,&ch,&itemRect);
  79.     which = FindItemByName((MenuHandle)*(long *)*(*ch)->contrlData,toName);
  80.     SetCtlValue(ch,which);
  81.     return(toName);
  82. }
  83.  
  84. /************************************************************************
  85.  * GetDIPopup - get the string a popup control is looking at
  86.  ************************************************************************/
  87. UPtr GetDIPopup(DialogPtr pd,short item,UPtr whatName)
  88. {
  89.     ControlHandle ch;
  90.     short itemType;
  91.     Rect itemRect;
  92.  
  93.     GetDItem(pd,item,&itemType,&ch,&itemRect);
  94.     GetItem((MenuHandle)*(long *)*(*ch)->contrlData,GetCtlValue(ch),whatName);
  95.     return(whatName);
  96. }
  97.     
  98. /************************************************************************
  99.  * SetDItemState - set the state of an item in a dialog
  100.  ************************************************************************/
  101. short SetDItemState(DialogPtr pd,short dItem,short on)
  102. {
  103.     ControlHandle ch;
  104.     short itemType;
  105.     Rect itemRect;
  106.  
  107.     GetDItem(pd,dItem,&itemType,&ch,&itemRect);
  108.     SetCtlValue(ch,on);
  109.     return(on);
  110. }
  111.  
  112. /************************************************************************
  113.  * GetDItemState - get the state of an item in a dialog
  114.  ************************************************************************/
  115. short GetDItemState(DialogPtr pd,short dItem)
  116. {
  117.     ControlHandle ch;
  118.     short itemType;
  119.     Rect itemRect;
  120.  
  121.     GetDItem(pd,dItem,&itemType,&ch,&itemRect);
  122.     return(GetCtlValue(ch));
  123. }
  124.  
  125. /************************************************************************
  126.  * DlgFilter - filter for normal dialogs
  127.  ************************************************************************/
  128. pascal Boolean DlgFilter(DialogPtr dgPtr,EventRecord *event,short *item)
  129. {
  130.     Rect r;
  131.     short type,itemN;
  132.     Handle itemH;
  133.     Point mouse;
  134.     static Point oldMouse;
  135.     GrafPtr oldPort;
  136.     long select;
  137.     extern ConnHandle CnH;
  138.     Boolean oldCmdPeriod=CommandPeriod;
  139.     
  140.     if (event->what==mouseDown || event->what==keyDown)
  141.         AlertTicks=0;
  142.     if (CnH) CMIdle(CnH);
  143.     if (!MiniMainLoop(event))
  144.         if (!CommandPeriod)
  145.             return(False);
  146.         else
  147.         {
  148.             *item = CANCEL_ITEM;
  149.             CommandPeriod = oldCmdPeriod;
  150.             return(True);
  151.         }
  152.     if (event->what==keyDown || event->what==autoKey) SpecialKeys(event);
  153.     if (event->what==keyDown || event->what==autoKey)
  154.     {
  155.         short key = event->message & charCodeMask;
  156.         if (event->modifiers&cmdKey)
  157.         {
  158.             short oldMenu = TheMenu;
  159.             MenuHandle mh = GetMHandle(EDIT_MENU);
  160.             if (mh)
  161.             {
  162.                 EnableItem(mh,0);
  163.                 if (select=MenuKey(key))
  164.                 {
  165.                     if (((select>>16)&0xffff)==EDIT_MENU)
  166.                         (void) DoModelessEdit(dgPtr,select&0xffff);
  167.                     if (oldMenu) HiliteMenu(oldMenu);
  168.                 }
  169.                 event->what=nullEvent;
  170.                 DisableItem(GetMHandle(EDIT_MENU),0);
  171.             }
  172.         }
  173.         else
  174.             switch (key)
  175.             {
  176.                 case enterChar:
  177.                 case returnChar:
  178.                     *item = ((DialogPeek)dgPtr)->aDefItem ? ((DialogPeek)dgPtr)->aDefItem : 1;
  179.                     return(True);
  180.                     break;
  181.             }
  182.     }
  183.     else if (event->what==activateEvt || event->what==updateEvt)
  184.     {
  185.         HiliteButtonOne(dgPtr);
  186.     }
  187.     else if (event->what==nullEvent)
  188.     {
  189.         if (AlertsTimeout && AlertTicks && AlertTicks<TickCount())
  190.         {
  191.             *item = ((DialogPeek)dgPtr)->aDefItem ? ((DialogPeek)dgPtr)->aDefItem : 1;
  192.             AlertTicks = 0;
  193.             return(True);
  194.         }
  195.         GetPort(&oldPort);
  196.         SetPort(dgPtr);
  197.         GetMouse(&mouse);
  198.         if (mouse.h==oldMouse.h && mouse.v==oldMouse.v) return(False);
  199.         oldMouse = mouse;
  200.         for (itemN=1;;itemN++)
  201.         {
  202.             itemH = nil;
  203.             GetDItem(dgPtr,itemN,&type,&itemH,&r);
  204.             if (!itemH) break;
  205.             if (PtInRect(mouse,&r))
  206.             {
  207.                 SetTopCursor((type & editText) ? iBeamCursor : arrowCursor);
  208.                 break;
  209.             }
  210.         }
  211.         SetPort(oldPort);
  212.     }
  213.     return(False);
  214. }
  215.  
  216. /************************************************************************
  217.  * CenterDialog - try to get a dialog centered on the screen
  218.  ************************************************************************/
  219. void CenterDialog(int template)
  220. {
  221.     DialogTHndl dTempl;
  222.     Rect r = qd.screenBits.bounds;
  223. #ifdef CAROLYN
  224.     SetRect(&r,0,0,512,342);
  225. #endif
  226.     r.top += GetMBarHeight();             
  227.     if ((dTempl=(DialogTHndl)GetResource('ALRT',template)) ||
  228.             (dTempl=(DialogTHndl)GetResource('DLOG',template)))
  229.         CenterRectIn(&(*dTempl)->boundsRect,&r);
  230. }
  231.  
  232. /************************************************************************
  233.  * TopCenterDialog - try to get a dialog centered on (the top of) the screen
  234.  ************************************************************************/
  235. void TopCenterDialog(int template)
  236. {
  237.     DialogTHndl dTempl;
  238.     Rect r = qd.screenBits.bounds;
  239. #ifdef CAROLYN
  240.     SetRect(&r,0,0,512,342);
  241. #endif
  242.     r.top += GetMBarHeight();             
  243.     if ((dTempl=(DialogTHndl)GetResource('ALRT',template)) ||
  244.             (dTempl=(DialogTHndl)GetResource('DLOG',template)))
  245.         TopCenterRectIn(&(*dTempl)->boundsRect,&r);
  246. }
  247.  
  248. /************************************************************************
  249.  * BottomCenterDialog - try to get a dialog centered on (the bottom of)
  250.  * the screen
  251.  ************************************************************************/
  252. void BottomCenterDialog(int template)
  253. {
  254.     DialogTHndl dTempl;
  255.     Rect r = qd.screenBits.bounds;
  256. #ifdef CAROLYN
  257.     SetRect(&r,0,0,512,342);
  258. #endif
  259.     r.top += GetMBarHeight();             
  260.     if ((dTempl=(DialogTHndl)GetResource('ALRT',template)) ||
  261.             (dTempl=(DialogTHndl)GetResource('DLOG',template)))
  262.         BottomCenterRectIn(&(*dTempl)->boundsRect,&r);
  263. }
  264.  
  265. /************************************************************************
  266.  * ThirdCenterDialog - try to get a dialog centered on (the top 1/3 of)
  267.  * the screen
  268.  ************************************************************************/
  269. void ThirdCenterDialog(int template)
  270. {
  271.     DialogTHndl dTempl;
  272.     Rect r = qd.screenBits.bounds;
  273. #ifdef CAROLYN
  274.     SetRect(&r,0,0,512,342);
  275. #endif
  276.     r.top += GetMBarHeight();             
  277.     if ((dTempl=(DialogTHndl)GetResource('ALRT',template)) ||
  278.             (dTempl=(DialogTHndl)GetResource('DLOG',template)))
  279.         ThirdCenterRectIn(&(*dTempl)->boundsRect,&r);
  280. }
  281.  
  282. /************************************************************************
  283.  * GlobalizeRgn - offset a region to global coords
  284.  ************************************************************************/
  285. void GlobalizeRgn(RgnHandle rgn)
  286. {
  287.     Point o;
  288.     
  289.     o.h = o.v = 0;
  290.     LocalToGlobal(&o);
  291.     OffsetRgn(rgn,o.h,o.v);
  292. }
  293.  
  294. /************************************************************************
  295.  * LocalizeRgn - offset a region to local coords
  296.  ************************************************************************/
  297. void LocalizeRgn(RgnHandle rgn)
  298. {
  299.     Point o;
  300.     
  301.     o.h = o.v = 0;
  302.     GlobalToLocal(&o);
  303.     OffsetRgn(rgn,o.h,o.v);
  304. }
  305.  
  306. /************************************************************************
  307.  * HiliteButtonOne - hilite the default button in a dialog
  308.  ************************************************************************/
  309. void HiliteButtonOne(DialogPtr dgPtr)
  310. {
  311.     GrafPtr oldPort;
  312.     short type;
  313.     Handle itemH;
  314.     Rect r;
  315.     
  316.     GetDItem(dgPtr,((DialogPeek)dgPtr)->aDefItem ? ((DialogPeek)dgPtr)->aDefItem : 1,&type,&itemH,&r);
  317.     if (type==btnCtrl+ctrlItem)
  318.     {
  319.         GetPort(&oldPort);
  320.         SetPort(dgPtr);
  321.         OutlineControl(itemH,!InBG&&FrontWindow()==dgPtr);
  322.         SetPort(oldPort);
  323.     }
  324. }
  325.  
  326. /************************************************************************
  327.  * PlotSICN, courtesy of Apple DTS
  328.  ************************************************************************/
  329. void PlotSICN(Rect *theRect, SICNHand theSICN, long theIndex) {
  330.              auto char     state;     /*saves original flags of 'SICN' handle*/
  331.              auto BitMap srcBits; /*built up around 'SICN' data so we can
  332. _CopyBits*/
  333.  
  334.              /* check the index for a valid value */
  335.              if ((GetHandleSize(theSICN) / sizeof(SICN)) > theIndex) {
  336.  
  337.                      /* store the resource's current locked/unlocked condition */
  338.                      state = HGetState(theSICN);
  339.  
  340.                      /* lock the resource so it won't move during the _CopyBits call
  341. */
  342.                      HLock(theSICN);
  343.  
  344.                      /* set up the small icon's bitmap */
  345.                      srcBits.baseAddr = (Ptr) (*theSICN)[theIndex];
  346.                      srcBits.rowBytes = 2;
  347.                      SetRect(&srcBits.bounds, 0, 0, 16, 16);
  348.  
  349.                      /* draw the small icon in the current grafport */
  350.                      CopyBits(&srcBits,&(*qd.thePort).portBits,&srcBits.bounds,
  351.                                         theRect,srcOr,nil);
  352.  
  353.                      /* restore the resource's locked/unlocked condition */
  354.                      HSetState(theSICN, state);
  355.              }
  356. }
  357.  
  358. /************************************************************************
  359.  *
  360.  ************************************************************************/
  361. void SavePosPrefs(UPtr name,Rect *r, Boolean zoomed)
  362. {
  363.     PositionHandle rez;
  364.     
  365.     if (!(rez=Get1NamedResource(SAVE_POS_TYPE,name)))
  366.     {
  367.         rez = NewH(PositionType);
  368.         if (!rez) return;
  369.         AddResource(rez,SAVE_POS_TYPE,Unique1ID(SAVE_POS_TYPE),name);
  370.         if (ResError()) {DisposHandle(rez); return;}
  371.     }
  372.     (*rez)->r = *r;
  373.     (*rez)->zoomed = zoomed;
  374.     ChangedResource(rez);
  375. }
  376.  
  377. /************************************************************************
  378.  *
  379.  ************************************************************************/
  380. void SavePosFork(short vRef,long dirId,UPtr name,Rect *r, Boolean zoomed)
  381. {
  382.     short refN;
  383.     Str31 scratch;
  384.     HFileInfo info;
  385.     long oldmdDat;
  386.     short err;
  387.     
  388.     if (HGetFileInfo(vRef,dirId,name,&info)) return;
  389.     oldmdDat = info.ioFlMdDat;
  390.     
  391.     refN=HOpenResFile(vRef,dirId,name,fsRdWrPerm);
  392.     if (refN<0)
  393.     {
  394.         HCreateResFile(vRef,dirId,name);
  395.         if (err=ResError()) return;
  396.         refN=HOpenResFile(vRef,dirId,name,fsRdWrPerm);
  397.         err=ResError();
  398.     }
  399.     if (refN>0)
  400.     {
  401.         SavePosPrefs(GetRString(scratch,POSITION_NAME),r,zoomed);
  402.         if (refN != SettingsRefN)
  403.         {
  404.             CloseResFile(refN);
  405.             if (!HGetFileInfo(vRef,dirId,name,&info))
  406.             {
  407.                 info.ioFlMdDat = oldmdDat;
  408.                 HSetFileInfo(vRef,dirId,name,&info);
  409.             }
  410.         }
  411.     }
  412. }
  413.  
  414. /************************************************************************
  415.  *
  416.  ************************************************************************/
  417. Boolean RestorePosPrefs(UPtr name,Rect *r, Boolean *zoomed)
  418. {
  419.     PositionHandle rez;
  420.     
  421.     if (rez=Get1NamedResource(SAVE_POS_TYPE,name))
  422.     {
  423.         *r = (*rez)->r;
  424.         *zoomed = (*rez)->zoomed;
  425.         return(True);
  426.     }
  427.     return(False);
  428. }
  429.  
  430. /************************************************************************
  431.  *
  432.  ************************************************************************/
  433. Boolean RestorePosFork(short vRef,long dirId,UPtr name,Rect *r, Boolean *zoomed)
  434. {
  435.     Str31 scratch;
  436.     short refN;
  437.     Boolean done;
  438.     
  439.     if ((refN=HOpenResFile(vRef,dirId,name,fsRdPerm))>0)
  440.     {
  441.         done = RestorePosPrefs(GetRString(scratch,POSITION_NAME),r,zoomed);
  442.         if (refN != SettingsRefN) CloseResFile(refN);
  443.         return(done);
  444.     }
  445.     return(False);
  446. }
  447.  
  448. /************************************************************************
  449.  *
  450.  ************************************************************************/
  451. Boolean PositionPrefsTitle(Boolean save,MyWindowPtr win)
  452. {
  453.     Rect r;
  454.     Boolean zoomed;
  455.     
  456.     if (save)
  457.     {
  458.         utl_SaveWindowPos(win,&r,&zoomed);
  459.         SavePosPrefs(LDRef(((WindowPeek)win)->titleHandle),&r,zoomed);
  460.     }
  461.     else
  462.     {
  463.         if (!RestorePosPrefs(LDRef(((WindowPeek)win)->titleHandle),&r,&zoomed))
  464.             {UL(((WindowPeek)win)->titleHandle); return(False);}
  465.         utl_RestoreWindowPos(win,&r,zoomed,1,FigureZoom,DefPosition);
  466.     }
  467.     UL(((WindowPeek)win)->titleHandle);
  468.     return(True);
  469. }
  470.  
  471. /************************************************************************
  472.  *
  473.  ************************************************************************/
  474. void DefPosition(MyWindowPtr win,Rect *r)
  475. {
  476.     Point corner;
  477.     utl_StaggerWindow(&((GrafPtr)win)->portRect,1,GetMBarHeight(),&corner,
  478.                                         GetRLong(PREF_STRN+PREF_NW_DEV));
  479.     *r = ((GrafPtr)win)->portRect;
  480.     OffsetRect(r,corner.h-r->left,corner.v-r->top);
  481. }
  482.  
  483. /************************************************************************
  484.  * GreyOutRoundRect - grey a rectangle
  485.  ************************************************************************/
  486. void GreyOutRoundRect(Rect *r,short r1, short r2)
  487. {
  488.     PenState oldState;
  489.     
  490.     GetPenState(&oldState);
  491.     PenMode(patBic);
  492.     PenPat(&qd.gray);
  493.     PaintRoundRect(r,r1,r2);
  494.     SetPenState(&oldState);
  495. }
  496.  
  497. /************************************************************************
  498.  * DrawMyControls - draw a window's controls
  499.  ************************************************************************/
  500. void DrawMyControls(WindowPeek win)
  501. {
  502.     ControlHandle cntl;
  503.     GrafPtr oldPort;
  504.     
  505.     GetPort(&oldPort);
  506.     SetPort(win);
  507.     DrawControls(win);
  508.     for (cntl=win->controlList;cntl;cntl=(*cntl)->nextControl)
  509.         if ((*cntl)->contrlRfCon=='GREY') GreyControl(cntl);
  510.     SetPort(oldPort);
  511. }
  512.  
  513. /************************************************************************
  514.  * SanitizeSize - make sure a rect is small enough to fit onscreen
  515.  ************************************************************************/
  516. void SanitizeSize(Rect *r)
  517. {
  518.     Rect gray = (**(RgnHandle *)GrayRgn)->rgnBBox;
  519.     short maxWi = gray.right-gray.left-4;
  520.     short maxHi = gray.bottom-gray.top - GetMBarHeight() - 2;
  521.     
  522.     if (r->right-r->left>maxWi) r->right = r->left+maxWi;
  523.     if (r->bottom-r->top>maxHi) r->bottom = r->top+maxHi;
  524. }
  525.  
  526.  
  527. /************************************************************************
  528.  * MyWinHasSelection - is there a selection in one of the te's?
  529.  ************************************************************************/
  530. Boolean MyWinHasSelection(MyWindowPtr win)
  531. {
  532.     TEHandle teh;
  533.     
  534.     if (win->txe) teh = win->txe;
  535.     else if (win->ste) teh = (*(STEHandle)win->ste)->te;
  536.     else return(False);
  537.     
  538.     return((*teh)->selStart != (*teh)->selEnd);
  539. }
  540. /************************************************************************
  541.  * HotRect - SFPutFile-style frame
  542.  ************************************************************************/
  543. void HotRect(Rect *r,Boolean on)
  544. {
  545.     Rect fr = *r;
  546.  
  547.     PenState oldPen;
  548.     InsetRect(&fr,-3,-3);
  549.     GetPenState(&oldPen);
  550.     PenPat(on ? &qd.black : &qd.white);
  551.     PenSize(2,2);
  552.     FrameRect(&fr);
  553.     SetPenState(&oldPen);
  554. }
  555.  
  556. /************************************************************************
  557.  * CursorInRect - see if the mouse is in a rectangle.  If so, set mouseRgn
  558.  *  to the rectangle, if not subtract rect from mouseRgn.
  559.  *    Note that the parameter is a Rect, not a Rect *; this avoids a temp var
  560.  *  for rects in handles.
  561.  ************************************************************************/
  562. Boolean CursorInRect(Point pt,Rect r,RgnHandle mouseRgn)
  563. {
  564.     RgnHandle punchRgn;
  565.         
  566.     /*
  567.      * if we're in the rect...
  568.      */
  569.     if (PtInRect(pt,&r))
  570.     {
  571.         RectRgn(mouseRgn,&r);
  572.         return(True);
  573.     }
  574.     /*
  575.      * otherwise, put a hole in the region
  576.      */
  577.     else if (punchRgn=NewRgn())
  578.     {
  579.         RectRgn(punchRgn,&r);
  580.         DiffRgn(mouseRgn,punchRgn,mouseRgn);
  581.         DisposeRgn(punchRgn);
  582.     }
  583.     return(False);
  584. }
  585.  
  586. /************************************************************************
  587.  * MaxSizeZoom - size the zoom rect of a window, using the maxes provided
  588.  ************************************************************************/
  589. void MaxSizeZoom(MyWindowPtr win,Rect *zoom)
  590. {
  591.     short zoomHi = zoom->bottom-zoom->top;
  592.     short zoomWi = zoom->right-zoom->left;
  593.     short hi, wi;
  594.     
  595.     if (win->hMax<0) UpdateMyWindow(win);
  596.     hi = win->vMax ?
  597.         win->vMax*win->vPitch+win->topMargin+(win->hBar ? GROW_SIZE : 0) :
  598.         (win->vBar ? win->minSize.v : zoomHi);
  599.     wi = win->hMax ?
  600.         win->hMax*win->hPitch+(win->vBar ? GROW_SIZE : 0) :
  601.         (win->hBar ? win->minSize.h : zoomWi);
  602.  
  603.     wi = MIN(wi,zoomWi); wi = MAX(wi,win->minSize.h);
  604.     hi = MIN(hi,zoomHi); hi = MAX(hi,win->minSize.v);
  605.     zoom->right = zoom->left+wi;
  606.     zoom->bottom = zoom->top+hi;
  607. }
  608.  
  609. /************************************************************************
  610.  * CurState - return a windows current state
  611.  ************************************************************************/
  612. Rect CurState(MyWindowPtr win)
  613. {
  614.     Point pt;
  615.     Rect curState;
  616.     
  617.     pt.h = pt.v = 0;
  618.     LocalToGlobal(&pt);
  619.     curState = ((GrafPtr)win)->portRect;
  620.     OffsetRect(&curState, pt.h, pt.v);
  621.     return(curState);
  622. }
  623.  
  624. /************************************************************************
  625.  * AboutSameRect - are two rects "about equal"
  626.  ************************************************************************/
  627. Boolean AboutSameRect(Rect *r1,Rect *r2)
  628. {
  629.     short *s1 = r1;
  630.     short *s2 = r2;
  631.     short i=4;
  632.     
  633.     for (;i--;s1++,s2++) if (ABS(*s1-*s2)>7) return(False);
  634.     return(True);
  635. }
  636.  
  637. /************************************************************************
  638.  * OutlineControl - outline the default button
  639.  ************************************************************************/
  640. void OutlineControl(ControlHandle cntl,Boolean blackOrWhite)
  641. {
  642.     Rect r =  (*cntl)->contrlRect;
  643.     PenState oldState;
  644.     
  645.     GetPenState(&oldState);
  646.     PenSize(3,3);
  647.     PenPat(blackOrWhite?((*cntl)->contrlRfCon=='GREY'?&qd.gray:&qd.black):&qd.white);
  648.     InsetRect(&r,-4,-4);
  649.     FrameRoundRect(&r,16,16);
  650.     SetPenState(&oldState);
  651. }
  652.  
  653. #ifdef DEBUG
  654. /************************************************************************
  655.  * ShowGlobalRgn - show a region in global coords
  656.  ************************************************************************/
  657. void ShowGlobalRgn(RgnHandle globalRgn,UPtr string)
  658. {
  659.     GrafPtr wmgr;
  660.     SAVE_PORT;
  661.     GetWMgrPort(&wmgr);
  662.     SetPort(wmgr);
  663.     InvertRgn(globalRgn);
  664.     if (EmptyRgn(globalRgn)) DebugStr("\pempty!;g");
  665.     DebugStr(string);
  666.     InvertRgn(globalRgn);
  667.     REST_PORT;
  668. }
  669.  
  670.  
  671. /************************************************************************
  672.  * 
  673.  ************************************************************************/
  674. void ShowLocalRgn(RgnHandle localRgn,UPtr string)
  675. {
  676.     GlobalizeRgn(localRgn);
  677.     ShowGlobalRgn(localRgn,string);
  678.     LocalizeRgn(localRgn);
  679. }
  680. #endif